/*
 * @Author: XuYang 
 * @Date: 2021-05-17 17:01:06 
 * @Last Modified by: XuYang
 * @Last Modified time: 2021-05-17 17:08:16
 */

import { Controller, Get, Inject, Provide, App } from "@midwayjs/decorator";
import { Application, Context } from "egg";
import { IResponse } from "../interface";
import { RoleService } from "../service/role";

@Provide()
@Controller('/role')
export class RoleController {
    @Inject()
    roleService: RoleService;
    
    @Inject()
    ctx: Context;
    
    @App()
    app: Application;

    /**
     * 获取所有的角色
     */
    @Get('/getAllRoles')
    async getAllRole():Promise<IResponse> {
        try{
            const data = await this.roleService.getAllRole();
            return {
                code: 0,
                message:'查询成功',
                data: data
            }
        }catch(e:any){
            return {
                code: -1,
                message: '查询失败',
                data: []
            }
        }
    }
}